package com.fcscs.ecms.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fcscs.cservice.ws.schema.commonconfigservice.CommonConfigInfo;
import com.fcscs.ecms.dao.ECMSCommonConfigDao;
import com.fcscs.ecms.domain.CommonConfig;
import com.fcscs.ecms.service.ECMSCommonConfigManager;

/**
 * @author pvttinh
 * 
 */

@Service("ecmsCommonConfigManager")
public class ECMSCommonConfigManagerImpl implements ECMSCommonConfigManager {

	@Autowired
	ECMSCommonConfigDao ecmsCommonConfigDao;

	@Override
	public List<CommonConfigInfo> getCommonConfigList(long orgId, long propertyId)
			throws Exception {
		// TODO Auto-generated method stub
		List<CommonConfigInfo> cciList = new ArrayList<CommonConfigInfo>();
		try{
			List<CommonConfig> ccList = this.ecmsCommonConfigDao.find((int)orgId, (int)propertyId);
			for(CommonConfig cc : ccList){
				CommonConfigInfo cci = new CommonConfigInfo();
				cci.setName(cc.getId().getName());
				cci.setValue(cc.getValue());
				
				cciList.add(cci);
			}
		}catch (Exception e) {
			// TODO: handle exception
			throw new Exception("Entertainment.MANAGER.getEntertainmentUrl() - " + e.getMessage());
		}
		
		return cciList;
	}
}
